package com.zzh.log;

import android.text.TextUtils;

import com.zzh.log_annotation.AddLog;

/**
 * @author zhangzhihao
 * @email zhangzhihao@gongjiangren.net
 * @date 2020-09-08
 * @desc
 */
@AddLog
public class LogU {


    private static UnifyLog unifyLog = new DefaultUnifyLog();
    private static boolean isPrint = true;

    public static void setUnifyLog(UnifyLog unifyLog) {
        LogU.unifyLog = unifyLog;
    }

    public static void setIsPrint(boolean isPrint) {
        LogU.isPrint = isPrint;
    }

    public static void print(Object obj, String msg) {
        if (unifyLog == null) {
            return;
        }
        if (isPrint && obj != null && !TextUtils.isEmpty(msg)) {
            unifyLog.print(obj.getClass().getName(), msg, null);
        }
    }

    public static void print(String objName, String msg) {
        if (unifyLog == null) {
            return;
        }
        if (isPrint && !TextUtils.isEmpty(objName) && !TextUtils.isEmpty(msg)) {
            unifyLog.print(objName, msg, null);
        }
    }

    public static void print(String objName, String msg, String time) {
        if (unifyLog == null) {
            return;
        }
        if (isPrint && !TextUtils.isEmpty(objName) && !TextUtils.isEmpty(msg)) {
            unifyLog.print(objName, msg, time);
        }
    }

    @AddLog
    public void test() {
        test2();
    }

    @AddLog
    public void test2() {
    }

}
